const joi = require('joi')

// 邮箱验证规则
const email = joi.string().email().required()

// 昵称验证
const nickname = joi.string().min(1).max(12).required()

// 密码 6-12位
const password = joi.string().pattern(/^[\S]{6,12}$/).required()

// 和密码相同且规则相同
const rePassword = joi.equal(joi.ref('password')).concat(password)

// id
const id = joi.number().integer().min(1).required()

// 介绍
const description = joi.string().required()

// 头像
const avatar = joi.string().dataUri()

exports.register_user_schema = {
    body: {
        email,
        nickname,
        password,
        rePassword
    }
}

exports.login_user_schema = {
    body: {
        email,
        password
    }
}

exports.update_user_schema = {
    body: {
        id,
        nickname,
        description,
        avatar
    }
}